//
//  XGVideoInfoModel.swift
//  TodayNews
//
//  Created by monkey on 2020/5/4.
//  Copyright © 2020 itcast. All rights reserved.
//

import HandyJSON

struct XGVideoInfoModel: HandyJSON
{
    var poster_url: String?
    var vwidth: Int = 0
    var vheight: Int = 0
    var main_url: String?
    
    var videoUrl: String? {
        guard let mainUrl = main_url,
            let data = Data(base64Encoded: mainUrl, options: .ignoreUnknownCharacters) else {
                return nil
        }
        
        return String(data: data, encoding: .utf8)
    }

    mutating func mapping(mapper: HelpingMapper)
    {
        mapper <<<
        self.vwidth <-- "video_list.video_1.vwidth"
        mapper <<<
        self.vheight <-- "video_list.video_1.vheight"
        mapper <<<
          self.main_url <-- "video_list.video_1.main_url"
    }
}
